package cs2340.todolist.model.account_management;

import cs2340.todolist.model.ToDoItem;

public class ItemInformationManager {
	
	private ToDoItem currentItem;
	
	/**
	 * constructor
	 */
	public ItemInformationManager() {
		
		currentItem = null;
		
	}
	
	public void setCurrentItem(ToDoItem item) {
		currentItem = item;
	}
	
	public ToDoItem getCurrentItem() {
		return currentItem;
	}

	/**
	 * @return the title of the current item
	 */
	public String getTitle() {
		return currentItem.getTitle();
	}
	
	/**
	 * @return the integer version of what type the current item is
	 */
	public int getTypeInt() {
		
		for(int i = 0; i < ToDoItemManager.TYPES.length; i++)
			if(ToDoItemManager.TYPES[i].equals(currentItem.getType()))
				return i;
		
		return -1;
		
	}
	
	/**
	 * @return a string representing the due date of the current item
	 */
	public String getDueDateString() {
		return currentItem.getDueDate().getMonth() + "/"
				+ currentItem.getDueDate().getDate() + "/"
				+ currentItem.getDueDate().getYear();
	}
	
	/**
	 * @return a string representing the time of the current item
	 */
	public String getTimeString() {
		return String.format("%d:%02d", currentItem.getDueDate().getHours(), currentItem.getDueDate().getMinutes());
	}
	
	/**
	 * @return - integer version of the recur type of the current item
	 */
	public int getRecurTypeInt() {
		
		for(int i = 0; i < ToDoItemManager.RECUR_TYPES.length; i++)
			if(ToDoItemManager.RECUR_TYPES[i].equals(currentItem.getRecurType()))
				return i;
		
		return -1;
		
	}
	
	/**
	 * @return the location string
	 */
	public String getLocationString() {
		return currentItem.getLocation().getName();
	}
	
	/**
	 * @return the description string
	 */
	public String getDescriptionString() {
		return currentItem.getDescription();
	}
	
	/**
	 * @return completed boolean
	 */
	public boolean getCompleted() {
		return currentItem.getCompleted();
	}
	
}
